package Z5;

import java.beans.*;
import java.io.*;

public class Zadanie2 {
	public static void main(String[] args) {
		String name = "test.xml";
		TestBean tb = new TestBean();
		tb.setName("Lolalala");
		tb.setNr(10000);
		try {
			XMLEncoder enc = new XMLEncoder(new BufferedOutputStream(
					new FileOutputStream(name)));
			enc.writeObject(tb);
			enc.close();
		} catch (FileNotFoundException exc) {
			exc.printStackTrace();
			System.exit(1);
		}
		try {
			XMLDecoder dec = new XMLDecoder(new BufferedInputStream(
					new FileInputStream(name)));
			Object obj = dec.readObject();
			TestBean testRead = (TestBean) obj;
			dec.close();
			System.out.println("Name: " + testRead.getName());
			System.out.println("Nr: " + testRead.getNr());

		} catch (FileNotFoundException exc) {
			exc.printStackTrace();
			System.exit(1);
		}
	}

	
		
	

}
